{
  Copyright 2012 Sergey Ostanin

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
}

unit SetEvaluationModelModifierEditor;

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls, StdCtrls,
  TestUiUtils, ModifierEditors, TestCore, Questions, CommonModifiers;

type
  TSetEvaluationModelModifierEditorFrame = class(TFrame, IModifierEditor)
    lblQuestionTypes: TLabel;
    rbDichotomic: TRadioButton;
    rbLax: TRadioButton;
  private
    FModifier: TSetEvaluationModelModifier;
    { private declarations }
  public
    procedure SetUp(Modifier: TModifier);
    procedure Commit;
    { public declarations }
  end;

implementation

{$R *.lfm}

{ TSetEvaluationModelModifierEditorFrame }

procedure TSetEvaluationModelModifierEditorFrame.SetUp(Modifier: TModifier);
var
  QuestionClass: TQuestionClass;
begin
  FModifier := Modifier as TSetEvaluationModelModifier;
  if FModifier.LaxEvaluation then
    rbLax.Checked := TRUE
  else
    rbDichotomic.Checked := TRUE;

  if FModifier.QuestionClasses.Count > 0 then
  begin
    for QuestionClass in FModifier.QuestionClasses do
      lblQuestionTypes.Caption := Format('%s%s  %s', [lblQuestionTypes.Caption,
        LineEnding, QuestionRegistry.GetTitle(QuestionRegistry.Find(QuestionClass.Kind))]);
    lblQuestionTypes.Visible := TRUE;
  end;
end;

procedure TSetEvaluationModelModifierEditorFrame.Commit;
begin
  FModifier.LaxEvaluation := rbLax.Checked;
end;

initialization

  ModifierEditorRegistry.Add(TSetEvaluationModelModifierEditorFrame, TSetEvaluationModelModifier);

end.

